package com.xiaoshuidi.cloud.module.contract.service.bill;

import com.xiaoshuidi.cloud.framework.common.pojo.PageResult;
import com.xiaoshuidi.cloud.module.bpm.mq.message.BpmProcessInstanceResultEvent;
import com.xiaoshuidi.cloud.module.contract.controller.admin.bill.vo.ownerOrder.*;
import com.xiaoshuidi.cloud.module.contract.controller.admin.contract.vo.HomeQueryVO;
import com.xiaoshuidi.cloud.module.contract.controller.admin.contract.vo.ownerContract.ContractHouseOwnerCancelReqVO;
import com.xiaoshuidi.cloud.module.contract.dal.dataobject.bill.OwnerOrderTransferDO;
import com.xiaoshuidi.cloud.module.contract.dal.dataobject.bill.RentOrderDO;
import com.xiaoshuidi.cloud.module.contract.dal.dataobject.contract.ContractHouseOwnerRoomRefDO;
import com.xiaoshuidi.cloud.module.contract.service.bill.dto.RentOrderCreateDTO;
import com.xiaoshuidi.cloud.module.contract.service.bill.dto.RentOrderQueryDTO;
import com.xiaoshuidi.cloud.module.contract.service.contract.dto.OwnerContractRentOrderDTO;
import com.xiaoshuidi.cloud.module.contract.vo.OwnerOrderTransferCallbackReqVO;
import com.xiaoshuidi.cloud.module.finance.api.finance.dto.BankTransferReqDTO;

import java.math.BigDecimal;
import java.util.List;

/**
 * 业主账单 Service 接口
 *
 * @author 合房租赁
 */
public interface OwnerOrderService {
    /**
     * 分页查询业主账单
     * @param pageReqVO
     * @return: com.xiaoshuidi.cloud.framework.common.pojo.PageResult<com.xiaoshuidi.cloud.module.contract.controller.admin.bill.vo.ownerOrder.OwnerOrderRespVO>
     */
    PageResult<OwnerOrderRespVO> getOwnerOrderPage(OwnerOrderPageReqVO pageReqVO);

    /**
     * 查询业主账单列表
     * @param pageReqVO
     * @return: java.util.List<com.xiaoshuidi.cloud.module.contract.controller.admin.bill.vo.ownerOrder.OwnerOrderRespVO>
     */
    List<OwnerOrderRespVO> getOwnerOrderList(OwnerOrderPageReqVO pageReqVO);

    /**
     *  业主合同创建账单
     * @param ownerContractRentOrderDTO
     * @return: void
     */
    void ownerContractCreateRentOrder(OwnerContractRentOrderDTO ownerContractRentOrderDTO);

    /**
     *  创建业主合同账单明细
     * @param rentOrderCreateList
     * @param typeCode
     * @param carryForwardDeposit 押金结转金额
     * @return: void
     */
    void createRentOrderAndOrderFees(List<RentOrderCreateDTO> rentOrderCreateList, String typeCode, BigDecimal carryForwardDeposit);

    /**
     * 业主合同退租账单处理
     *
     * @param reqVo
     * @param ownerRoomRef
     * @return: void
     */
    RentOrderCreateDTO ownerWithdrawal(ContractHouseOwnerCancelReqVO reqVo, ContractHouseOwnerRoomRefDO ownerRoomRef);

    void cancelUnpaidOrder(ContractHouseOwnerCancelReqVO reqVo);

    /**
     * 根据业务ID删除账单及账单明细
     *
     * @param businessId 业务ID (合同id)
     * @param orderType  订单类型
     */
    void deleteOrderByBusinessId(Long businessId, String orderType);

    /**
     * 账单ID查询业主账单基本信息
     * @param orderId
     * @return: com.xiaoshuidi.cloud.module.contract.controller.admin.bill.vo.ownerOrder.OwnerOrderRespVO
     */
    OwnerOrderInfoRespVO getOwnerOrderInfo(Long orderId);

    /**
     * 判断业主合同是否有退租
     * @param orderId
     * @return: java.lang.Boolean
     */
    Boolean checkOwnerOrderRentOut(Long orderId);

    /**
     * 业主账单支付完成处理续租合同账单
     * @param orderId 被付款的账单ID
     * @return: void
     */
    void ownerOrderPaidHandleRenewalOrders(Long orderId);

    /**
     * 交租
     * @param req
     * @return: void
     */
    void payRent(BankTransferReqDTO req);

    /**
     * 通过业主合同ID校验业主账单是否已支付
     * @param contractId
     * @param contractType 0业主合同 1业主续租合同
     * @return: java.lang.Boolean
     */
    Boolean checkOwnerOrderPaid(Long contractId, Integer contractType);

    /**
     * 处理续租合同账单
     * @param contractId 原合同编号
     * @return: void
     */
    void handleRenewalOrder(Long contractId);

    /**
     * 条件查询账单
     * @param param
     * @return: java.util.List<com.xiaoshuidi.cloud.module.contract.dal.dataobject.bill.RentOrderDO>
     */
    List<RentOrderDO> getListByParam(RentOrderQueryDTO param);

    /**
     * 业主应付账单列表分页
     * @param queryDTO
     * @return: com.xiaoshuidi.cloud.framework.common.pojo.PageResult<com.xiaoshuidi.cloud.module.contract.controller.admin.bill.vo.ownerOrder.OwnerOrderPageRespVO>
     */
    PageResult<OwnerOrderPageRespVO> getOwnerOrderHomePage(HomeQueryVO queryDTO);

    void suspend(OwnerOrderSuspendReqVO reqVO);

    /**
     * 生成委托付款单
     */
    void createRenterOrderTransfer();


    /**
     * 批量发起委托账单审批
     */
    void batchApprovalRenterOrder();

    /**
     * 业主打款审批回调
     *
     * @param event
     */
    void approvalResult(BpmProcessInstanceResultEvent event);

    /**
     * 获取业主账单打款详情
     *
     * @param id
     * @return {@link OwnerOrderApprovalDetailVO}
     */
    OwnerOrderApprovalDetailVO ownerOrderApprovalDetailById(Long id);


    /**
     * 业主账单id
     *
     * @param id
     */
    void ownerOrderCreateApproval(Long id);

    PageResult<OwnerOrderTransferDO> getTransferPage(OwnerOrderTransferPageReqVO reqVO);

    void transfer(OwnerOrderTransferReqVO reqVO, String operator);

    List<OwnerOrderTransferDO> getTransferList(String[] asList);

    OwnerOrderTransferDO getTransferDetail(Long id);

    OwnerOrderTransferPageRespVO getTransferSummary(OwnerOrderTransferPageReqVO reqVO);

    void transferCallback(OwnerOrderTransferCallbackReqVO reqVO);
}
